<template lang="">
    <div>
        您好，{{username}}<br/>
        个性签名:{{sign}}

        发布文章<br/>
        <van-field v-model='form.title' label='标题'/>
        <van-field rows=3 cols=5 type='textarea' v-model='form.content' lable='内容'/>
        <van-button @click='add'>添加</van-button>

        <br/><br/><h1>------------------------------------</h1>
        <h1>展示文章</h1>
        <br/>
        <van-button @click='my'>我的文章</van-button><br/>
        <table border=1 cellspacing=0>
            <tr>
                <td>id</td>
                <td>标题</td>
                <td>内容</td>
            </tr>
            <tr v-for='i in alist'>
                    <td>{{i.id}}</td>
                    <td>{{i.title}}</td>
                    <td>{{i.content}}</td>
                </tr>
        </table>
    </div>
</template>

<script>
export default {
    data(){
        return{
            username:localStorage.getItem('username'),
            sign:localStorage.getItem('sign'),
            form:{'userid':localStorage.getItem('userid')},
            alist:[],
            uid:0
        }
    },
    methods: {
        add(){
            this.axios.post('auser/articleM',this.form).then(res=>{
                if(res.data.code == 200){
                    this.getlist()
                    this.form={'userid':localStorage.getItem('userid')}
                }
            })
        },
        getlist(){
            this.axios.get('auser/articleM?uid='+this.uid).then(res=>{
                this.alist = res.data.list
            })
        },
        //我的文章
        my(){
            this.uid = this.form.userid
            this.getlist()
        }
    },
    mounted() {
        this.getlist()
    }
}
</script>

<style lang="">

</style>